//
//  StatusBottomView.swift
//  sinaWeibo
//
//  Created by liii on 16/7/25.
//  Copyright © 2016年 liii. All rights reserved.
//

import UIKit
import SnapKit

class StatusBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
     
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // 搭建界面
    private func setupUI() {
        
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        
        // 添加子控件
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(supportBtn)
        addSubview(leftLineView)
        addSubview(rightLineView)
        
        // 布局子控件
        retweetBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.height.equalTo(self.snp_height)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetBtn.snp_top)
            make.left.equalTo(retweetBtn.snp_right)
            make.width.equalTo(retweetBtn.snp_width)
            make.height.equalTo(retweetBtn.snp_height)
            
        }
        supportBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentBtn.snp_top)
            make.left.equalTo(commentBtn.snp_right)
            make.width.equalTo(commentBtn.snp_width)
            make.height.equalTo(commentBtn.snp_height)
            make.right.equalTo(self.snp_right)
        }
        
        // 添加分隔线
        leftLineView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.width.equalTo(1)
        }
        rightLineView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            make.width.equalTo(1)
        }
        
    }
    
    // 子控件
    private var retweetBtn: UIButton = UIFactory.buttonWithTitle("转发", fontSize: 12, color: UIColor.darkGrayColor(), backgroundImage: nil, image: "timeline_icon_retweet")
    private var commentBtn: UIButton = UIFactory.buttonWithTitle("评论", fontSize: 12, color: UIColor.darkGrayColor(), backgroundImage: nil, image: "timeline_icon_comment")
    private var supportBtn: UIButton = UIFactory.buttonWithTitle("点赞", fontSize: 12, color: UIColor.darkGrayColor(), backgroundImage: nil, image: "timeline_icon_unlike")
    // 分隔线
    private var leftLineView: UIView = UIFactory.lineViewColor()
    private var rightLineView: UIView = UIFactory.lineViewColor()
}
